import { Button, List, Modal, Result, WhiteSpace } from 'antd-mobile'
import { Brief } from 'antd-mobile/lib/list/ListItem'
import React from 'react'
import { connect } from 'react-redux'
import Cookies from 'js-cookie'

function Person(props) {
    const userInfo = props.user.userInfo || {}
    const logout = (e) => {
        Modal.alert("退出","确认退出帐号码?",[{
            text: "取消",
            onPress: () => console.log("cancel")
        },{
            text: "确定",
            onPress: () => {
                Cookies.remove("user_id")
                props.dispatch({type: "Reset_User",data: null})
            }
        } 
        ])
    }
    return<div>
        <Result title={userInfo.username} message={userInfo.company} />
        <List renderHeader={() => "  相关信息  "}>
            <List.Item>
                <Brief>职位： {userInfo.post}</Brief>
                <Brief>简介： {userInfo.info}</Brief>
                <Brief>薪资： {userInfo.salay}</Brief>
            </List.Item>
        </List>
        <WhiteSpace/>
        <Button type="warning" onClick={logout}>退出登陆</Button>
    </div>
}

export default connect(state => ({user: state.user}))(Person)